package com.train.classeval.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.train.classeval.entity.User;
import com.train.classeval.mapper.UserMapper;
import com.train.classeval.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xs
 * @since 2021-09-11
 */
@Service

public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    @Transactional
    public int updatePassword(User user) {
        user.setUpdateDate(LocalDateTime.now());
        int i = userMapper.updateById(user);
        return i;
    }

    @Override
    public User loginUser(String username) {
        final User user = userMapper.selectUserByUsername(username);
        return user;
    }

    @Override
    public List<User> findAllUser() {
        List<User> allUser = userMapper.findAllUser();
        return allUser;
    }
}
